<template>
  <div style="padding：0">
    <van-button type="default" @click="getList">获取数据</van-button>
    <van-button type="primary" @click="toNext">主要按钮</van-button>
    <van-cell title="选择单个日期" :value="date" is-link @click="show = true" />
    <van-calendar v-model="show" @confirm="onConfirm" />
  </div>
</template>
<script>
import { Button, Calendar, Cell, Toast } from 'vant'
import { getFormList } from '@/common/baseReq'
export default {
  data () {
    return {
      date: '',
      show: false
    }
  },
  components: {
    [Button.name]: Button,
    [Calendar.name]: Calendar,
    [Cell.name]: Cell
    // [Toast.name]: Toast
  },
  created () {
    console.log(process.env)
  },
  methods: {
    formatDate (date) {
      return `${date.getMonth() + 1}/${date.getDate()}`
    },
    onConfirm (date) {
      this.show = false
      this.date = this.formatDate(date)
    },
    // toast
    getList () {
      let formdata = {
        page: 1,
        pageSize: 10
      }
      Toast.loading({
        message: '加载中...',
        forbidClick: true,
        loadingType: 'spinner',
        duration: 0
      })
      getFormList(formdata).then(res => {
        Toast.clear()
        console.log(res)
      })
    },
    toNext () {
      console.log('1111111')

      this.getList()
    }
  }
}
</script>
